package com.xintoucloud.pbs.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xintoucloud.pbs.dao.NewsManagementDao;
import com.xintoucloud.pbs.entity.DynamicNews;
import com.xintoucloud.pbs.model.DynamicNewsShowVo;
import com.xintoucloud.pbs.service.NewsManagementService;


@Service
@Transactional
public class NewsManagementServiceImpl implements NewsManagementService {
	@Autowired
	private NewsManagementDao nmDao;
	
	@Override
	public DynamicNewsShowVo getOne(int nid) {
		DynamicNewsShowVo newsVo = nmDao.getOneShowVo(nid);
		return newsVo;
	}

	@Override
	//@Transactional
	public List<DynamicNewsShowVo> list() {
		//List<DynamicNews> list = new ArrayList<>();
		List<DynamicNewsShowVo> listVo = new ArrayList<>();
		listVo = nmDao.list();
//		for(DynamicNews n: list) {
//			DynamicNewsShowVo dv = new DynamicNewsShowVo();
//			dv.setNid(n.getNid());
//			dv.setTitle(n.getTitle());
//			dv.setSource(n.getSource());
//			dv.setCreatetime(n.getCreatetime());
//			dv.setNewspic(n.getNewspic());
//			dv
//		}
		return listVo;
	}

	@Override
	public boolean add(DynamicNews d) {
		return (int)nmDao.add(d)>0;
	}

	@Override
	public Boolean delete(int nid) {
		return nmDao.delete(nid);
	}

	@Override
	public void update(DynamicNews d) {
		nmDao.update(d);
	}

}
